using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

namespace ASP_TF2LogParser.UserControls
{
    public partial class WeaponListControl : System.Web.UI.UserControl
    {
        double totalKills = 0.0;

        protected void Page_Load( object sender, EventArgs e )
        {

        }

        public string GenerateWeaponUrl( string weaponName, string weaponId )
        {
            string returnUrl = string.Empty;

            returnUrl = "<a href='Weapon.aspx?weaponId=" + weaponId + "'>" + weaponName + "</a>";

            return returnUrl;
        }

        public string GenerateClassUrl( string classId )
        {
            string returnUrl = string.Empty;

            LogParser.Collections.ClassList classList = new LogParser.Collections.ClassList();
            LogParser.GameObjects.Class tempClass = classList.GetClass( Convert.ToInt32( classId ) );

            returnUrl = "<a href='Class.aspx?classId=" + classId + "'>" + tempClass.LongName + "</a>";

            return returnUrl;
        }

        /// <summary>
        /// Total kill percentage
        /// </summary>
        /// <param name="kills">Number of kills for a given weapon</param>
        /// <returns></returns>
        public string GetKillPercentage( int kills )
        {
            string killPercentage = string.Empty;


            if ( totalKills == 0.0 )
                totalKills = LogParser.DA.KillsStatsModel.GetKillsTotalCount();
            


            double killPerc = ( ( double ) ( Convert.ToDouble( kills ) ) / ( Convert.ToDouble( totalKills ) ) ) * 100;
            killPercentage = killPerc.ToString();

            killPercentage = string.Format( "{0:0.00}", killPerc );

            if ( killPercentage == "NaN" )
                killPercentage = "0.00";

            return killPercentage;
        }



    }
}